﻿using System;

namespace DatabaseService.DatabaseDAO
{
    /// <summary>
    /// 存储过程业务模型
    /// </summary>
    public class ProcedureEntityMapper : TableModelMapper
    {
        private string _column1;
        private string _column2;
        private string _column3;

        //过程返回结果集列名
        public string Column1 { set => _column1 = value; }
        public string Column2 { set => _column2 = value; }
        public string Column3 { set => _column3 = value; }
        //过程返回结果集列名


        /// <summary>
        /// 存储过程返回的第一列的值
        /// </summary>
        public string result1 { get => _column1 ?? ""; }
        /// <summary>
        /// 存储过程返回的第二列的值
        /// </summary>
        public string result2 { get => _column2 ?? ""; }
        /// <summary>
        /// 存储过程返回的第三列的值
        /// </summary>
        public string result3 { get => _column3 ?? ""; }

        //一般存储过程返回ret,msg
        /// <summary>
        /// 存储过程返回的ret
        /// </summary>
        public int ret
        {
            get
            {
                try
                {
                    //用Convert，就是为了不能转化时抛出异常，返回-1
                    return Convert.ToInt32(this.result1);
                }
                catch (Exception)
                {
                    //转换失败
                    return -1;
                }
            }
        }
        /// <summary>
        /// 存储过程返回的msg
        /// </summary>
        public string msg { get => (this.result2 ?? "").Trim(); }
        //一般存储过程返回ret,msg

        /// <summary>
        /// 继承此类的子类不能再自定义路径
        /// </summary>
        /// <returns></returns>
        public sealed override string GetMappperPath()
        {
            return base.GetMappperPath();
        }
    }
}
